package com.kfm.am.synchronize;

public class Test {

    public static void main(String[] args) {
        Operator op = new Operator();
        Thread add = new Thread(() -> {
//            synchronized (op) {
                op.add();
//            }

        });
        Thread sub = new Thread(() -> {
//            synchronized (op){
                op.sub();
//            }
        });

        add.start();
        sub.start();

        try {
            add.join();
            sub.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(op.getNumber());
    }
}
